package com.example.checkqufuface.Utils;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.example.baselibrary.Bean.CheckResultBean;
import com.example.checkqufuface.R;

public class ChangeFaceResult {

    public static ChangeFaceResult instance;

    public static synchronized ChangeFaceResult getInstance() {
        if (null == instance) {
            instance = new ChangeFaceResult();
        }
        return instance;
    }

    //请检票界面 修改

    public void changeFace(int type, CheckResultBean checkResultBean, Context context, LinearLayout linearLayout, LinearLayout llMessageTow, ImageView emoView,TextView tvPass, TextView result, TextView messageTitle, TextView messageOne
            , TextView messageTwo, TextView messageThree, TextView messageFirst) {
        switch (type) {
            case 1:  //请检票界面

                linearLayout.setBackgroundResource(R.drawable.shape_result_blue);

                emoView.setImageResource(R.mipmap.ic_launcher);

                result.setText(R.string.please_check_in);
                tvPass.setVisibility(View.VISIBLE);
                result.setTextColor(context.getResources().getColor(R.color.color_duck_blue));

                messageTitle.setTextColor(context.getResources().getColor(R.color.color_deep_violet));
                messageTitle.setBackgroundResource(R.drawable.shape_result_blue);

                llMessageTow.setVisibility(View.GONE);

                messageFirst.setVisibility(View.VISIBLE);
                messageFirst.setText(R.string.welcome);
                messageFirst.setTextColor(context.getResources().getColor(R.color.color_duck_blue));

                break;

            case 2:  //无效票 该票已检

                linearLayout.setBackgroundResource(R.drawable.shape_result);

                emoView.setImageResource(R.mipmap.ic_launcher);

                tvPass.setVisibility(View.VISIBLE);
                result.setText(checkResultBean.getMessage());
                result.setTextColor(context.getResources().getColor(R.color.color_red));


                messageTitle.setTextColor(context.getResources().getColor(R.color.color_red_small));
                messageTitle.setBackgroundResource(R.drawable.shape_result_title);

                llMessageTow.setVisibility(View.GONE);

                messageFirst.setVisibility(View.VISIBLE);
                messageFirst.setText(checkResultBean.getMessage());
                break;

            case 3:  //检票成功

                linearLayout.setBackgroundResource(R.drawable.shape_result_green);

                emoView.setImageResource(R.mipmap.ic_launcher);

                result.setText(R.string.please_pass);
                tvPass.setVisibility(View.VISIBLE);
                result.setTextColor(context.getResources().getColor(R.color.color_duck_green));

                messageTitle.setTextColor(context.getResources().getColor(R.color.color_deep_violet));
                messageTitle.setBackgroundResource(R.drawable.shape_result_blue);

                llMessageTow.setVisibility(View.VISIBLE);
                String name = checkResultBean.getMessage();
                if (name.contains(",")) {
                    name.substring(0, name.length() - 1);
                }
                messageOne.setText("票名: " + name);
                messageTwo.setText("票号：" + checkResultBean.getData().getBarcodeNo());
                messageThree.setText("可通行人数：" + checkResultBean.getData().getPassPersonSum() + "人");

                messageFirst.setVisibility(View.GONE);
                break;

            case 4:  //需要人脸录入

                linearLayout.setBackgroundResource(R.drawable.shape_result_blue);

                emoView.setImageResource(R.mipmap.ic_launcher);

                result.setText(R.string.this_ticket_requires_face_entry);
                tvPass.setVisibility(View.GONE);
                result.setTextColor(context.getResources().getColor(R.color.color_duck_blue));

                messageTitle.setTextColor(context.getResources().getColor(R.color.color_deep_violet));
                messageTitle.setBackgroundResource(R.drawable.shape_result_blue);

                llMessageTow.setVisibility(View.GONE);

                messageFirst.setVisibility(View.VISIBLE);
                messageFirst.setText(R.string.this_ticket_requires_face_entry_why);
                messageFirst.setTextColor(context.getResources().getColor(R.color.color_duck_blue));

                break;

            case 5:  //二维码编号不存在（无效票，该票已退订，该票不能过此闸机，无效票，证件信息不存在）

                linearLayout.setBackgroundResource(R.drawable.shape_result);

                emoView.setImageResource(R.mipmap.ic_launcher);

                result.setText(checkResultBean.getMessage());
                tvPass.setVisibility(View.VISIBLE);
                result.setTextColor(context.getResources().getColor(R.color.color_red));


                messageTitle.setTextColor(context.getResources().getColor(R.color.color_red_small));
                messageTitle.setBackgroundResource(R.drawable.shape_result_title);

                llMessageTow.setVisibility(View.GONE);

                messageFirst.setVisibility(View.VISIBLE);
                messageFirst.setText(checkResultBean.getMessage());
                break;

        }

    }

    public void changeFacePick(int type, int number, Context context, LinearLayout linearLayout, LinearLayout llMessageTow, ImageView emoView,TextView tvPass, TextView result, TextView messageTitle, TextView messageOne
            , TextView messageTwo, TextView messageThree, TextView messageFirst) {
        switch (type) {
            case 10:
                linearLayout.setBackgroundResource(R.drawable.shape_result_blue);

                emoView.setImageResource(R.mipmap.ic_launcher);

                result.setText(R.string.now_check_tick);
                tvPass.setVisibility(View.VISIBLE);
                result.setTextColor(context.getResources().getColor(R.color.color_duck_blue));

                messageTitle.setTextColor(context.getResources().getColor(R.color.color_deep_violet));
                messageTitle.setBackgroundResource(R.drawable.shape_result_blue);

                llMessageTow.setVisibility(View.GONE);

                messageFirst.setVisibility(View.VISIBLE);
                messageFirst.setText(R.string.welcome);
                messageFirst.setTextColor(context.getResources().getColor(R.color.color_duck_blue));
                break;
            case 20:
                linearLayout.setBackgroundResource(R.drawable.shape_result);

                emoView.setImageResource(R.mipmap.ic_launcher);

                result.setText(R.string.fail_try_again);
                tvPass.setVisibility(View.VISIBLE);
                result.setTextColor(context.getResources().getColor(R.color.color_red));


                messageTitle.setTextColor(context.getResources().getColor(R.color.color_red_small));
                messageTitle.setBackgroundResource(R.drawable.shape_result_title);

                llMessageTow.setVisibility(View.GONE);

                messageFirst.setVisibility(View.VISIBLE);
                messageFirst.setText(R.string.fail_try_again);
                break;

            case 30:
                linearLayout.setBackgroundResource(R.drawable.shape_result_green);

                emoView.setImageResource(R.mipmap.ic_launcher);

                result.setText(R.string.please_pass);
                tvPass.setVisibility(View.VISIBLE);
                result.setTextColor(context.getResources().getColor(R.color.color_duck_green));

                messageTitle.setTextColor(context.getResources().getColor(R.color.color_deep_violet));
                messageTitle.setBackgroundResource(R.drawable.shape_result_blue);

                llMessageTow.setVisibility(View.VISIBLE);
                messageThree.setText("可通行人数：" + number + " 人");
                messageFirst.setVisibility(View.GONE);
                break;
        }
    }

}
